<?php
include_once 'class/LogParser.acalss.inc';
include_once 'class/LogReader.aclass.inc';
class FailedAttemptsLogParser extends LogParser {
	private $pattern = '%(?P<date>(?P<month>\d{2})/(?P<day>\d{2})/(?P<year>\d{4})),(?P<time>\d{2}:\d{2}:\d{2}),(?P<Message_Type>[\w ]*),(?P<UserName>[\w\d./@\-_:]*),(?P<GroupName>[\w\d./@\-_:+]*),(?P<Caller_Id>[\w.\-:=]*),(?P<Authen_Failure_Code>[\w\s]*),(?P<Author_Failure_Code>[\w\s]*),(?P<Author_Data>[\w\s/:]*),(?P<Nas_Port>[\d]*),(?P<NAS_IP_Address>[\d.]*),(?P<Access_Device>[\w]*),(?P<ExtDB_Info>[\w]*),(?P<Reason>[\w]*)%';


	protected function parser($log) {
		$matches = null;
		if(0 === preg_match($this->pattern, $log, $matches))
		return false;


		return $matches;
	}
	public function getDBVersion($log) {
		$res = array(
			'date' => $log['year']."-".$log['month']."-".$log['day']." ".$log['time'],
			'message_type' => $log['Message_Type'],
			'username' => $log['UserName'],
			'groupname' => $log['GroupName'],
			'caller_id' => $log['Caller_Id'],
			'authen_failure_code' => $log['Authen_Failure_Code'],
			'author_failure_code' => $log['Author_Failure_Code'],
			'author_Data' => $log['Author_Data'],
			'nas_port' => $log['Nas_Port'],
			'nas_ip_address' => $log['NAS_IP_Address'],
			'access_device' => $log['Access_Device'],
			'extdb_info' => $log['ExtDB_Info'],
			'reason' => $log['Reason'],
			);
			
		return $res;
	}
	
public function getName() {
		return 'failed_att';
	}
}
?>